package com.forezp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.forezp.service.DeviceService;
import com.forezp.service.conf.ResponseResult;
import com.github.pagehelper.PageInfo;
import com.service.bean.Device;

@RestController
@RequestMapping("/device")
public class DeviceController {

	@Autowired
	private DeviceService deviceService;

	// 列表
	@RequestMapping("/getDeviceList")
	public ResponseResult getTypeList(@RequestBody Device device, @RequestParam("pageNumber") Integer pageNumber,
			@RequestParam("pageSize") Integer pageSize) {
		PageInfo<Device> devicePage = deviceService.getPage(device, pageNumber, pageSize);
		return ResponseResult.ok(devicePage);
	}

	// 修改
	@RequestMapping("/updateDevice")
	public ResponseResult updateDevice(@RequestBody Device device) {
		Integer a = deviceService.deviceUpdate(device);
		return ResponseResult.ok(a);
	}

	// 注册
	@RequestMapping("/register")
	public ResponseResult register(@RequestParam("ids")Integer[] ids,
			@RequestParam("typeId") Integer typeId) {
		Integer a=deviceService.registerDevice(ids, typeId);
		return ResponseResult.ok(a);
	}
}
